package com.nervenets.web.redis.domain.common;

import com.nervenets.web.enumeration.TypeType;
import com.nervenets.web.hibernate.domain.Type;
import com.nervenets.web.redis.RedisSetDomain;
import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
public class TypeStored extends RedisSetDomain {
    private long typeId;
    private TypeType type;
    private String logo;
    private String name;
    private int queue;
    private boolean system;

    @Override
    public String getField() {
        return String.valueOf(typeId);
    }

    @Override
    public String getKey() {
        return String.format("T_V1_%s", String.format("%04d", typeId).substring(0, 4));
    }

    public TypeStored(long typeId) {
        this.typeId = typeId;
    }

    public TypeStored(Type type) {
        this.typeId = type.getId();
        this.type = type.getType();
        this.logo = type.getLogo();
        this.name = type.getName();
        this.queue = type.getQueue();
        this.system = type.isSystem();
    }
}
